import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home.vue'
import Map from '@/views/map.vue'
import config from '@/common/config'
import geohash from '@/views/geohash.vue'
import tech from '@/views/tech.vue'
import gitee from '@/views/gitee.vue'
import google from '@/views/google.vue'

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
}
const routes = [
  {
    path: '/',
    redirect: '/home/map'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children: [
      {
        path: 'map',
        name: 'Map',
        component: Map
      },
      {
        path: 'geohash',
        name: config.geohash,
        component: geohash
      },
      {
        path: 'tech',
        name: config.tech,
        component: tech
      },
      {
        path: 'gitee',
        name: config.gitee,
        component: gitee
      },
      {
        path: 'googles2',
        name: config.google,
        component: google
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
